package indiwood.model.service;

import indiwood.model.MagazineListVO;
import indiwood.model.MagazineVO;
import indiwood.model.PagingBean;
import indiwood.model.dao.MagazineDAO;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

@Service
public class MagazineServiceImpl implements MagazineService {
	@Resource(name = "magazineDAOImpl")
	private MagazineDAO magazineDAO;
	@Override
	public void write(MagazineVO mvo) {
		System.out.println(mvo + "service");
		magazineDAO.write(mvo);
	}
	@Override
	public MagazineVO showContent(int no) {
		magazineDAO.updateCount(no);
		return magazineDAO.showContent(no);
	}
	@Override
	public MagazineVO showContentNoHit(int no) {
		return magazineDAO.showContent(no);
	}
	@Override
	public MagazineListVO magazineList(String pageNo) {
		if (pageNo == null || pageNo == "")
			pageNo = "1";
		List<MagazineVO> list = magazineDAO.magazineList(pageNo);
		int total = magazineDAO.totalContent();
		PagingBean paging = new PagingBean(total, Integer.parseInt(pageNo));
		MagazineListVO lvo = new MagazineListVO(list, paging);
		return lvo;
	}
	@Override
	public void updateBoard(MagazineVO mvo) {
		magazineDAO.updateBoard(mvo);
	}
	@Override
	public void deleteBoard(String no) {
		magazineDAO.deleteBoard(no);
	}
}
